/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import java.sql.Connection;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 *
 * @author havn
 */
public class ListenerContext implements ServletContextListener {

    public void contextInitialized(ServletContextEvent sce) {
        ServletContext context = sce.getServletContext();
        String url = (String) context.getAttribute("DB_URL");
        String user = (String) context.getAttribute("DB_USER");
        String pass = (String) context.getAttribute("DB_PASS");
        DBHelper db = new DBHelper(url, user, pass);
        context.setAttribute("db", db);
    }

    public void contextDestroyed(ServletContextEvent sce) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
